4b039efa26f664c4b7484692cccba5bb983cc20d,server/src/test/java/org/candlepin/sync/ImporterTest.java,ImporterTest,testImportNoProductDir,#,536
Before Change
importFiles.put(ImportFile.UPSTREAM_CONSUMER.fileName(), mock(File.class));
try {
i.importObjects(owner, importFiles, co);
}
catch (RuntimeException e) {
assertEquals(e.getMessage(), "Done with the test");
After Change
public void testImportNoProductDir()
throws IOException, ImporterException {
RulesImporter ri = mock(RulesImporter.class);
OwnerCurator oc = mock(OwnerCurator.class);
Importer i = new Importer(null, null, ri, oc, null, null, null,
null, config, null, null, null, i18n, null, null, su, null);
Owner owner = mock(Owner.class);
ConflictOverrides co = mock(ConflictOverrides.class);
Map<String, File> importFiles = getTestImportFiles();
File ruleDir = mock(File.class);
File[] rulesFiles = createMockJsFile(mockJsPath);
when(ruleDir.listFiles()).thenReturn(rulesFiles);
File actualmeta = createFile("meta.json", "0.0.3", new Date(),
"test_user", "prefix");
// this is the hook to stop testing. we confirm that the archive component tests
// are passed and then jump out instead of trying to fake the actual file
// processing.
doThrow(new RuntimeException("Done with the test")).when(ri).importObject(
any(Reader.class));
importFiles.put(ImportFile.META.fileName(), actualmeta);
importFiles.put(ImportFile.RULES_FILE.fileName(), rulesFiles[0]);
importFiles.put(ImportFile.PRODUCTS.fileName(), null);
importFiles.put(ImportFile.ENTITLEMENTS.fileName(), null);
importFiles.put(ImportFile.UPSTREAM_CONSUMER.fileName(), mock(File.class));
ee.expect(RuntimeException.class);
ee.expectMessage("Done with the test");
i.importObjects(owner, importFiles, co);
}
@Test